<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Qcloud\Cos\Tests;

class TestHelper
{
    public static function nuke($bucket)
    {
        try {
            $cosClient = new \Qcloud\Cos\Client(["region" => getenv("COS_REGION"), "credentials" => ["appId" => getenv("COS_APPID"), "secretId" => getenv("COS_KEY"), "secretKey" => getenv("COS_SECRET")]]);
            $result = $cosClient->listObjects(["Bucket" => $bucket]);
            if($result->get("Contents")) {
                foreach ($result->get("Contents") as $content) {
                    $cosClient->deleteObject(["Bucket" => $bucket, "Key" => $content["Key"]]);
                }
            }
            $cosClient->deleteBucket(["Bucket" => $bucket]);
            while (true) {
                $result = $cosClient->ListMultipartUploads(["Bucket" => $bucket, "Prefix" => ""]);
                if(count($result["Uploads"]) == 0) {
                } else {
                    foreach ($result["Uploads"] as $upload) {
                        try {
                            $rt = $cosClient->AbortMultipartUpload(["Bucket" => $bucket, "Key" => $upload["Key"], "UploadId" => $upload["UploadId"]]);
                            print_r($rt);
                        } catch (\Exception $e) {
                            print_r($e);
                        }
                    }
                }
            }
        } catch (\Exception $e) {
        }
    }
}

?>